<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理 - 易买网</title>
<link type="text/css" rel="stylesheet" href="../css/style.css" />
<script type="text/javascript" src="../scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../scripts/function.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/laypage/laypage.js"></script>
 <script type="text/javascript">
 var search = function(pageCode){
	  var url="${pageContext.request.contextPath}/UserServlet";
	  var data={'pageCode':pageCode,'op':'allUser'};
	  $.post(url,data,function(result){
				$("#data").html('');
				 
				$("#data").append("<tr><th>用户名</th><th>真实姓名</th><th>性别</th><th>Email</th><th>手机</th><th>操作</th></tr>");	
					
				$.each(result.beanList,function(idx,user){
					$("#data").append("<tr><td class='first w4 c'>"+user.username+"</td><td class='w1 c'>"+user.userrealname+"</td><td class='w2 c'>"+user.usersex+"</td><td>"+user.useremail+"</td><td class='w4 c'>"+user.userphone+"</td><td class='w1 c'><a href='${pageContext.request.contextPath}/UserServlet?op=queryUserId&u_id="+user.u_id+"'>修改</a> <a class='manageDel' href='javascript:deleteUserId("+user.u_id+")'>删除</a></td></tr>");
					
				})
				
				
				laypage({
					cont : 'fenye',  //容器id：存放分页
					pages : result.totalPage, //得到总页数
					curr:  result.pageCode || 1,  //当前页
					skip: true, //是否开启跳页
					skin: '#AF0000',  //页码的颜色
					groups: 10,  //
					jump : function(obj, first) {
						if (!first) {   //首次加载不执行，并传递当前页：obj.curr
							search(obj.curr);  //调用函数
						}
					}
				}); 
				
				
			  },"json")			 
 }
 search(1);
 
  var deleteUserId=function(u_id){
	 var url="${pageContext.request.contextPath}?op=deleteUserId";
	 var data={'u_id':u_id}
	 $.get(url,data,function(result){
		 if(result=='true'){
			 alert("删除成功!");
			 search(1);//刷新数据
		 }else{
			 alert("删除失败!");
		 }
	 },'text')
	 
 }  
 </script>
</head>
<body>
<jsp:include page="menu.jsp" />
	<div class="main">
		<h2>用户管理</h2>
    
		 <div class="manage"> 
		 
			 <table class="list" id="data">
				<!-- <tr>
					<th>用户名</th>
					<th>真实姓名</th>
					<th>性别</th>
					<th>Email</th>
					<th>手机</th>
					<th>操作</th>
				</tr>  -->
				
				<!-- <tr>
					<td class="first w4 c">admin</td>
					<td class="w1 c">张三丰</td>
					<td class="w2 c">男</td>
					<td>fengsan.zhang@prd.com</td>
					<td class="w4 c">13888888888</td>
					<td class="w1 c"><a href="user-modify.jsp">修改</a> <a class="manageDel" href="javascript:void(0)">删除</a></td>
				</tr>
				<tr>
					<td class="first w4 c">jack</td>
					<td class="w1 c">杨二郎</td>
					<td class="w2 c">男</td>
					<td>fengsan.zhang@prd.com</td>
					<td class="w4 c">13888888888</td>
					<td class="w1 c"><a href="user-modify.jsp">修改</a> <a class="manageDel" href="javascript:void(0)">删除</a></td>
				</tr> -->
			 </table>
	
   </div> 
	
	  <div id="fenye"></div>

	</div>
<!-- 	<div class="clear"></div> -->
   <!--   <div class="pager">
				<ul class="clearfix">
					<li><a >首页</a></li>
					<li>...</li>
					<li><a >4</a></li>
					<li class="current">5</li>
                    <li><a >6</a></li>
                    <li>...</li>
					<li><a >尾页</a></li>
				</ul>
  </div> -->
  

</div>
<div id="footer">
	Copyright &copy; 2013 云和学院 All Rights Reserved. 京ICP证1000001号</div>
</body>
</html>
